/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package weka;

import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.Border;

/**
 *
 * @author Utilisateur
 */
public class MainWindow extends JFrame{
    private String file ;
    private String tree ;
    private JButton bouton;
    private JButton boutonInsert;
    private JButton boutonVisu;
    private JTextArea textArea;
    private JMenuItem exportXML;
    private Etude etude;
  //  private File xmlFile;

    public Etude getEtude() {
        return etude;
    }

    public void setEtude(Etude etude) {
        this.etude = etude;
    }

    public String getTree() {
        return tree;
    }

    public void setTree(String tree) {
        this.tree = tree;
    }
    private JLabel text;
    private JTextField textField;

    public JTextArea getTextArea() {
        return textArea;
    }

    public JTextField getTextField() {
        return textField;
    }

    public void setFile(String file) {
        this.file = file;
    }

    public JLabel getText() {
        return text;
    }

    public JButton getBoutonInsert() {
        return boutonInsert;
    }

    public JButton getBoutonVisu() {
        return boutonVisu;
    }
    
    public MainWindow(){
		super();
		build();//On initialise notre fenêtre
	}

    public String getFile() {
        return file;
    }
    
    private void build() {
        setTitle("Bi Project"); //On donne un titre à l'application
        setSize(400,395); //On donne une taille à notre fenêtre
        
        JMenuBar menuBar = new JMenuBar();
        JMenu fichier = new JMenu("Fichier");
        
        JMenuItem chargerArff = new JMenuItem(new ChargerArffAction(this,"Charger un ARFF"));
	fichier.add(chargerArff);
        
        exportXML = new JMenuItem(new exportXMLAction(this,tree,"Exporter en XML"));
        exportXML.setEnabled(false);
	fichier.add(exportXML);
        
        //JMenuItem Importxls2arff = new JMenuItem(new xsl2csvAction(this,"Importer un XLS"));
	//fichier.add(Importxls2arff);
        
        JMenuItem quitter = new JMenuItem(new QuitterAction("Quitter"));
        fichier.add(quitter);

        menuBar.add(fichier);

        JMenu aide = new JMenu("?");

        JMenuItem aPropos = new JMenuItem(new AProposAction(this, "A propos"));
        aide.add(aPropos);

        menuBar.add(aide);

        setJMenuBar(menuBar);
        setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
        setResizable(true); //On permet le redimensionnement
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer lors du clic sur la croix
        setContentPane(buildContentPane());
    }

    public JMenuItem getExportXML() {
        return exportXML;
    }
    
    private JPanel buildContentPane(){
		JPanel panel = new JPanel();
                panel.setLayout(new FlowLayout());
		//panel.setBackground(Color.white);
                Border etched = BorderFactory.createLineBorder(Color.BLACK);
                Border bordTextArea = BorderFactory.createTitledBorder(etched, "Statistiques");
                
		textField = new JTextField(15);
                textField.setFocusable(false);
                text = new JLabel("Fichier");
                bouton = new JButton(new ChargerArffAction(this,"Charger un ARFF"));
                boutonVisu = new JButton(new VisualisationAction(this, "Visualisation J48"));
                boutonVisu.setEnabled(false);
                boutonInsert = new JButton(new InsererAction(this, "Insérer un élément"));
                //boutonInsert.setEnabled(false);
                textArea = new JTextArea(15,30);
                textArea.setBorder(bordTextArea);
                textArea.setFocusable(false);
                textArea.setAutoscrolls(true);
                
                ButtonGroup bg = new ButtonGroup();
                JPanel pan = new JPanel(new FlowLayout());
                Border border = BorderFactory.createTitledBorder("Examples");
                pan.setBorder(border);
                JRadioButton br1 = new JRadioButton("un");
                JRadioButton br2 = new JRadioButton("deux");
                JRadioButton br3 = new JRadioButton("trois");
                // ajout des boutons radio dans le groupe bg
                   bg.add(br1);
                   pan.add(br1);
                   bg.add(br2);
                   pan.add(br2);
                   bg.add(br3);
                   pan.add(br3);
                   
                
                panel.add(text);
                panel.add(textField);
                panel.add(bouton);
                panel.add(textArea);
                panel.add(boutonVisu);
                panel.add(boutonInsert);
                panel.add(pan);
		return panel;
	}    
}
